package com.gitee.wsl.mathematics.matrix.mat2.ext

import com.gitee.wsl.mathematics.matrix.mat2.Matrix2
import com.gitee.wsl.mathematics.matrix.mat2.MutableMatrix2
import com.gitee.wsl.unit.angle.AngleUnit
import com.gitee.wsl.unit.angle.ext.cos
import com.gitee.wsl.unit.angle.ext.sin
import com.gitee.wsl.unit.angle.toRadians

val<T:Number> Matrix2<T, *, *>.rotation: AngleUnit
    get() = atan2(m10, m00).toRadians()

fun<T:Number> MutableMatrix2<T, *, *>.setRotate(angle: AngleUnit){
    val cos = angle.cos() + zero
    val sin = angle.sin() + zero
    m00 = cos
    m10 = sin

    m01 = -sin
    m11 = cos
}